home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-04-20 | 1.1 KB | 46 lines |
- import java.awt.*;
- import java.awt.event.*;
- import java.io.Serializable;
- import java.util.Vector;
-
- public class Clicker extends Component
- implements Serializable, ActionListener
- {
- private Vector listeners = new Vector();
-
- public void setBackground(Color c) {
- super.setBackground( c );
- repaint();
- }
-
- public Color getBackground() {
- return super.getBackground();
- }
-
- public synchronized void addActionListener(ActionListener a) {
- listeners.addElement(a);
- }
-
- public synchronized void removeActionListener(ActionListener a) {
- listeners.removeElement(a);
- }
-
- public void actionPerformed(ActionEvent e) {
- Vector targets;
-
- synchronized (this) {
- targets = (Vector)listeners.clone();
- }
-
- ActionEvent actionEvt = new ActionEvent(this, 0, null);
- for (int i = 0; i < targets.size(); i++) {
- ActionListener target = (ActionListener)targets.elementAt(i);
- target.actionPerformed(actionEvt);
- }
- }
-
- public Dimension getMinimumSize() {
- return new Dimension(100, 100);
- }
- }
-